#ifndef __OSA_TIME_H__
#define __OSA_TIME_H__

#include "osa_common.h"

#define OSA_MAX_TIMESTAMP	UINT64_MAX

EXTERN_C_BLOCKSTART

DLL_API uint64_t osa_get_timestamp(void); /* get current time stamp, in ticks */
DLL_API void osa_set_timestamp(uint64_t ts);	/* set current time stamp, in ticks */

INLINE uint64_t osa_timestamp_diff(uint64_t old_t, uint64_t new_t) /* new_t always newer than old_t */
{
	return new_t - old_t;
}

INLINE uint64_t osa_timestamp_diff32(uint32_t old_t, uint32_t new_t) /* new_t always newer than old_t */
{
	return new_t - old_t;
}

DLL_API bool osa_is_timeout(uint64_t timestamp, uint64_t timeout); /* return true if timeout */
DLL_API uint64_t osa_timestamp_to_ms(uint64_t timestamp); /* convert time stamp ticks to millisecond */
DLL_API uint64_t osa_ms_to_timestamp(uint64_t ms); /* convert millisecond to time stamp ticks */

EXTERN_C_BLOCKEND



#endif /* __OSA_TIME_H__ */
